package com.qlshouyu.gateway.bootclientdemo.controller;

//import com.qlshouyu.gateway.client.block.starter.LoadBalancerBootgateway;
import com.qlshouyu.gateway.client.model.Application;
import com.qlshouyu.gateway.client.reactor.starter.LoadBalancerBootgateway;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/bgtest/app")
public class ApplicationController {
    @Autowired
    LoadBalancerBootgateway bootgateway;

    @GetMapping
    public Object getApplication(String code) {
        try {
            return bootgateway.getApplicationByCode(code);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "error";
    }

    @PostMapping
    public Object createApp(@RequestBody Application application) {
        try {
            return bootgateway.createApplication(application);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "error";
    }

    @GetMapping("/service")
    public Object getService() {
        try {
            return bootgateway.getServiceList();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "error";
    }
}
